#include "VError.h"

VError* VError::singleton = 0;

VError::VError()
{
    this->icon = new QIcon(MPictures::get_instance()->m_pictures.value("icon"));

    this->popup_box = new QMessageBox(this);
    this->popup_box->setWindowTitle("Bombworld - Erreur");
    this->popup_box->setWindowIcon(*this->icon);

    this->h_spacer = new QSpacerItem(250, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);
    this->layout = (QGridLayout*)this->popup_box->layout();
    layout->addItem(this->h_spacer, this->layout->rowCount(), 0, 1, layout->columnCount());

    CDesign::get_instance()->change_color_widget(this->popup_box);
}

VError::~VError()
{
}

void VError::popup_login_error()
{
    this->popup_box->setText("Echec de la connexion.");
    this->popup_box->exec();
}

void VError::popup_login_warning()
{
    this->popup_box->setText("Veuillez renseigner tous les champs.");
    this->popup_box->exec();
}

VError* VError::get_instance()
{
    if(!singleton)
    {
        singleton = new VError;
    }

    return singleton;
}
